package com.cloud.server.system.feign.fallback;

import com.cloud.common.core.base.ApiResponse;
import com.cloud.server.system.feign.TestFeignService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @Auther: zhangxun
 * @Date: 2020/8/12 21:04
 */
@Slf4j
@Component
public class TestServiceFallback implements FallbackFactory<TestFeignService> {
//    @Override
//    public TestService create(Throwable throwable) {
//        return new TestService() {
//            @Override
//            public String hello(String name) {
//                log.error("调用febs-server-system服务出错", throwable);
//                return "调用出错";
//            }
//        };
//    }
    @Override
    public TestFeignService create(Throwable throwable) {
        return name -> {
            log.error("调用test-server服务出错", throwable);
            return ApiResponse.respond("调用出错");
        };
    }
}